package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	OutLogEventNew           = "wms.OutLogNew"
	OutLogEventBeforeCreate  = "wms.OutLogBeforeCreate"
	OutLogEventBeforeUpdate  = "wms.OutLogBeforeUpdate"
	OutLogEventBeforeSave    = "wms.OutLogBeforeCreate wms.OutLogBeforeUpdate"
	OutLogEventAfterCreate   = "wms.OutLogAfterCreate"
	OutLogEventAfterUpdate   = "wms.OutLogAfterUpdate"
	OutLogEventAfterSave     = "wms.OutLogAfterCreate wms.OutLogAfterUpdate"
	OutLogEventDelete        = "wms.OutLogDelete"
	OutLogAccessControlEvent = "wms.OutLogAccessControl"
)

func GetOutLogConfig() *mgo.DocConfig {
	return OutLog_Config
}

var OutLog_Config *mgo.DocConfig

func init() {
	OutLog_Config = NewOutLogConfig()
}
func NewOutLogConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "wms.OutLog",
		Fields: []string{
			"sn", "item", "type", "department", "isCanceled", "num", "numCanBack", "batchCode", "batchPrice", "cost", "heapCode", "pos", "applier", "usage", "link", "linkTo", "note", "createBy", "createName",
		},
		RelationFields: []string{
			"item", "type", "department",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"item": {
				Config:     GetItemSkuConfig,
				DocName:    "ItemSku",
				JoinType:   "O",
				KeyInside:  "itemId",
				KeyOutSide: "id",
			},
			"type": {
				Config:     GetIOTypeConfig,
				DocName:    "IOType",
				JoinType:   "O",
				KeyInside:  "typeId",
				KeyOutSide: "id",
			},
			"department": {
				Config:     GetDepartmentConfig,
				DocName:    "Department",
				JoinType:   "O",
				KeyInside:  "departmentId",
				KeyOutSide: "id",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
